// pages/workOrder/orderProcess/index.js
import requestUtil from '../../../baseRequest'
import urls from '../../../requestUrl'

Page({

    /**
     * 页面的初始数据
     */
    data: {
        stepList: ['接单出发', '接车出发', '到达目的地', '服务评价', '完成工单'],
        current: 4,
        orderId: '',
        orderInfo: {}
    },

    /**获取工单状态信息 */
    getOrderInfoById() {
        requestUtil.getRequest(urls.workOrder.getInfo + this.data.orderId, {}, (res) => {
            this.setData({
                orderInfo: res,
                current: res.status
            })
        }, () => {})
    },

    /**进入工单表单填写页面 */
    toOrderForm({ currentTarget }) {
        console.log('currentTarget', currentTarget)
        let process = currentTarget.id
        wx.navigateTo({
            url: '/pages/formTemplate/index?orderId=' + this.data.orderId + '&process=' + process + '&routerFrom=process'
        })
    },
    /**进入查看表单数据 */
    toShowFormDetail({ currentTarget }) {
        // wx.showToast({
        //     title: '暂未开放',
        //     icon: 'none'
        // })
        // return
        console.log('currentTarget', currentTarget)
        let process = currentTarget.id
        wx.navigateTo({
            url: '/pages/workOrder/processDetail/index?orderId=' + this.data.orderId + '&process=' + process
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        let orderId = options.orderid || 'dfb9fd1df3dc4fd1b141825efaa07137'
        this.setData({ orderId })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.getOrderInfoById()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})